<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLogBalanceTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('log_balance', function (Blueprint $table) {
            $table->increments('id')->unsigned()->comment('收入/支出/提现表');
            $table->integer('user_id')->comment('用户ID');
            $table->decimal('user_balance', 10, 2)->comment('用户余额');
            $table->enum('action', ['top_up', 'consume', 'withdraw', 'refund'])->comment('动作：充值进账、消费支出、提现');
            $table->decimal('amount', 10, 2)->comment('交易金额');
            $table->string('remarks')->nullable()->comment('备注');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('log_balance');
    }
}
